package com.example.demo.config.login;

import com.example.demo.config.DataSourceContextHolder;
import com.example.demo.constant.RedisConstant;
import com.example.demo.util.Redis2Service;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.SessionListener;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * fileName:MySessionListener
 * description: shiro会话监听
 * author: LJV
 * createTime:2022/4/9 16:23
 * version:1.0.0
 */
@Component
public class MySessionListener implements SessionListener {

    @Autowired
    private Redis2Service redis2Service;

    /**
     * 会话创建时触发
     *
     * @param session
     */
    @Override
    public void onStart(Session session) {
        System.out.println("会话创建：" + session.getId());
    }

    /**
     * 会话过期时触发
     *
     * @param session
     */
    @Override
    public void onExpiration(Session session) {
        System.out.println("会话过期：" + session.getId());
    }

    /**
     * 退出/会话过期时触发
     *
     * @param session
     */
    @Override
    public void onStop(Session session) {
        System.out.println("会话停止：" + session.getId());
    }

}
